package reflect;

import java.lang.reflect.Method;
import java.lang.reflect.Modifier;

public class Test1 {
    public static void main(String[] args) throws Exception {
        Class cls = Class.forName("reflect.Person");
        Object obj = cls.newInstance();

      Method[ ] methods = cls.getMethods();
        for (Method method: methods
             ) {
            if (method.getParameterCount()/*判断是否有参数*/
                    == 0 && method.getModifiers() == Modifier.PUBLIC){/*判断是否为public*/
                method.invoke(obj);
            }
        }
    }
}
